RidgeRun Metadata/Streaming Protocols/RTMP
The RidgeRun Metadata documentation from RidgeRun is presently being developed. |
Introduction
Real-Time Messaging Protocol (RTMP) is a TCP-based protocol originally developed by Macromedia (later Adobe) for low-latency streaming of audio, video, and data. Though Flash is now deprecated, RTMP remains widely used in modern streaming pipelines — particularly as an ingest protocol for media servers and CDNs.
RTMP transmits multiplexed audio, video, control, and metadata over a single persistent TCP connection, making it suitable for live broadcasting and real-time applications.
Key Characteristics
- TCP-based: Uses port 1935 by default; ensures reliable delivery.
- Multiplexed streams: Combines audio, video, and metadata in one connection.
- Low latency: Typically under 1 second in optimal conditions.
- Chunk-based transmission: Splits messages into manageable chunks.
- Persistent connection: Requires a continuous TCP session.
- Metadata embedding: Supports AMF-encoded key/value data (e.g.,
onMetaData
,onTextData
).
Benefits and Limitations
Benefits
- Low latency: Sub-second delay, ideal for live interaction.
- Simple ingest: Widely used for sending live streams to CDNs and media servers.
- Tooling support: Compatible with FFmpeg, GStreamer, OBS, and major platforms.
- In-band metadata: Supports time-aligned metadata via AMF tags (e.g.,
onMetaData
). - Reliable delivery: TCP ensures ordered, complete transmission of media data.
Limitations
- Playback deprecated: No longer supported in modern browsers (Flash-dependent).
- No built-in security: Use RTMPS (over TLS) for encryption.
- TCP overhead: Less efficient in lossy or high-latency networks.
- Codec limitations: Typically limited to H.264 and AAC; newer codecs (e.g., AV1, Opus) have limited support.
RidgeRun compatible products
RidgeRun products that support metadata streaming over RTMP include:
- SEI: Metadata is embedded as SEI NAL units and carried within the video bitstream. Fully compatible with RTMP.
- RTMP: To enable flexible metadata workflows over RTMP, RidgeRun extended the standard
flvmux
andflvdemux
elements to support metadata injection and extraction
Usage Implications (RTMP+ Metadata)
Method | Description | Implications |
---|---|---|
RTMP + SEI | SEI is embedded in the H.264/H.265 bitstream and, when sent via RTMP inside FLV without transcoding, it’s typically preserved end-to-end and can be extracted with seiextract .
|
Benefits
|
RTMP + FLV (RTMP) | RidgeRun supports injecting session-level metadata into FLV streams over RTMP using fields like meta-string , meta-binary , and GstFlvMeta . Metadata is inserted at flvmux and extracted at the demuxer
|
Benefits
|
Examples
This section presents reference pipelines that demonstrate various combinations of metadata transmission and reception using RidgeRun’s products over the RTMP protocol. Each example typically includes a sender, a receiver, and the corresponding output, showcasing the complete end-to-end flow. The pipelines highlight different metadata injection and extraction methods, such as SEI and FLV (RTMP).
RTMP SERVER
RTMP SERVER
Launch a local RTMP server using the command below. This allows you to push streams via rtmpsink
and receive them via rtmpsrc
, making it a common setup for local end-to-end testing of RTMP pipelines with metadata injection and extraction.
docker run --rm -it -p 1935:1935 -p 8080:80 --name rtmp alfg/nginx-rtmp
SEI
- Sender
gst-launch-1.0 -v \ videotestsrc is-live=true ! video/x-raw,framerate=30/1 ! \ x264enc tune=zerolatency key-int-max=60 byte-stream=true ! \ h264parse config-interval=-1 ! \ seiinject metadata="HELLO WORLD" ! \ h264parse config-interval=-1 ! video/x-h264,stream-format=avc,alignment=au ! \ flvmux streamable=true ! \ rtmpsink location="rtmp://127.0.0.1/live/test"
- Receiver
GST_DEBUG=*seiextract*:MEMDUMP gst-launch-1.0 -v \ rtmpsrc location="rtmp://localhost/live/mystream" do-timestamp=true ! \ flvdemux ! h264parse ! seiextract ! fakesink silent=false
- OutPut
0:00:03.001499949 83893 0x5ada291f8240 MEMDUMP seiextract gstseiextract.c:299:gst_sei_extract_extract_h264_data:<seiextract0> --------------------------------------------------------------------------- 0:00:03.001505054 83893 0x5ada291f8240 MEMDUMP seiextract gstseiextract.c:299:gst_sei_extract_extract_h264_data:<seiextract0> The extracted data is: 0:00:03.001510345 83893 0x5ada291f8240 MEMDUMP seiextract gstseiextract.c:299:gst_sei_extract_extract_h264_data:<seiextract0> 00000000: 48 45 4c 4c 4f 20 57 4f 52 4c 44 00 HELLO WORLD. 0:00:03.001514089 83893 0x5ada291f8240 MEMDUMP seiextract gstseiextract.c:299:gst_sei_extract_extract_h264_data:<seiextract0> ---------------------------------------------------------------------------
RTMP
- Sender
gst-launch-1.0 -e \ videotestsrc is-live=true pattern=smpte ! video/x-raw,framerate=30/1 ! \ x264enc tune=zerolatency speed-preset=ultrafast key-int-max=60 byte-stream=false ! \ video/x-h264,stream-format=avc,alignment=au ! \ flvmux name=mux streamable=true meta-string="Hello World" ! \ rtmpsink location="rtmp://127.0.0.1/live/test"
- Receiver
GST_DEBUG=flv*:6,flvdemux:6,gstflv*:6 \ gst-launch-1.0 -m \ rtmpsrc location="rtmp://127.0.0.1/live/test" ! \ flvdemux attach-flvmeta=true flv-meta-signal=true name=d \ d.video ! identity silent=false ! fakesink sync=false \ d.audio ! fakesink sync=false
- OutPut
0:00:13.553384696 731996 0x5598d3195920 DEBUG flvdemux gstflvdemux.c:692:gst_flv_demux_clear_tags:<d> clearing taglist 0:00:13.553393214 731996 0x5598d3195920 DEBUG flvdemux gstflvdemux.c:406:gst_flv_demux_parse_metadata_item:<d> tag name Server, tag type 2 0:00:13.553400465 731996 0x5598d3195920 DEBUG flvdemux gstflvdemux.c:475:gst_flv_demux_parse_metadata_item:<d> Server => (string) Hello World
Documentation
References
- Adobe RTMP Specification 1.0
- FFmpeg - RTMP Protocol
- NGINX RTMP Module
- Wowza - What is RTMP
- GStreamer - FLV/RTMP Support
- OBS Studio - Streaming with RTMP